<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手动同步</title>
    <style>
        div {
            padding-bottom: 15px;
            margin: 15px;
        }
        button {
            margin-right: 40px;
        }
		input {
			margin-right: 15px;
		}
        .title_label {
			font-size: 20px;
		}
		
		.cont_button {
			margin-left: 60px;
		}
    </style>
</head>
<body>
    <div class="title_label">
        <strong>同&nbsp;步&nbsp;单&nbsp;据</strong>
    </div>
    <div class="cont_button">
        原材料出库单：
        <button id="syncMaterialOut" onclick="syncData('syncMaterialOut')">同步</button>
    </div>
    <div class="cont_button">
        销售订单：
        <button id="syncSalesOrder" onclick="syncData('syncSalesOrder')">同步</button>
    </div>
    <div class="cont_button">
        产成品入库单：
        <button id="syncProduction" onclick="syncData('syncProduction')">同步</button>
<!--        <button id="syncProductionTest" onclick="syncData('syncProductionTest')">测试</button>-->
    </div>
</body>
<script>

    function syncData(type) {
        let url;
        if (type === 'syncMaterialOut') {
            url = 'materialout/add';
        } else if (type === 'syncSalesOrder') {
            url = 'fxtSaleOrder/add';
        } else if (type === 'syncProduction') {
            url = 'production/add';
        } else if(type === 'syncProductionTest') {
            url = 'production/test';
        }

        // 这里使用fetch模拟请求，实际应用中应替换为实际的API请求
        fetch('http://localhost:16000/'+url)
        .then(response => response.json())
        .then(data => {
            console.log('同步成功:', data);
            alert('同步成功！');
        })
        .catch((error) => {
            console.error('同步失败:', error);
            alert('同步失败！');
        });
    }

    </script>
</html>